package com.kang.controller;

import com.kang.bean.Type;
import com.kang.commons.Result;
import com.kang.service.TypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/type")
@Slf4j
public class TypeController {

    @Autowired
    private TypeService typeService;

    @GetMapping(value = "/queryAllType")
    public Result queryAllType(){
        log.info("=============== queryAllType =============");
        //调用service
        List<Type> typeList = typeService.queryAllType();
        //返回响应
        return Result.success(typeList);
    }

    @PutMapping
    public Result addType(Type type){
        typeService.add(type);
        return Result.success();
    }
}
